﻿using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text;

namespace Marmat.Common.Http
{
    /// <summary>
    /// HttpApi的方法描述
    /// </summary>
    public class ApiActionDescriptor
    {
        internal ApiActionDescriptor(Type declaringType, MethodInfo member, object[] arguments)
        {
            this.DeclaringType = declaringType;
            this.Method = member;
            this.Arguments = arguments;
        }

        /// <summary>
        /// 在Body请求时需要忽略的参数
        /// </summary>
        internal readonly List<string> ignoreArgumentCollection = new();

        /// <summary>
        /// 获取实际调用的接口类型。
        /// </summary>
        public Type DeclaringType { get; }

        /// <summary>
        /// 获取关联的方法信息
        /// </summary>
        public MethodInfo Method { get; }

        /// <summary>
        /// 获取Api调用时传入的参数值
        /// </summary>
        public object[] Arguments { get; }

        /// <summary>
        /// 获取管理方法的返回类型。
        /// </summary>
        public Type ReturnType { get => this.Method.ReturnType; }

        /// <summary>
        /// 获取方法的返回类型是否属于 Void 类型。
        /// </summary>
        public bool IsVoid { get => this.ReturnType.FullName == "System.Void"; }
    }
}
